//
//  VisitorView.swift
//  WB
//
//  Created by KenLiang on 16/4/7.
//  Copyright © 2016年 KenLiang. All rights reserved.
//

import UIKit

class VisitorView: UIView {
    // MARK:- 快速通过xib创建类的方法
    class func visitorView() -> VisitorView {
        return NSBundle.mainBundle().loadNibNamed("VisitorView", owner: nil, options: nil).first as! VisitorView
    }
    @IBOutlet weak var iconView: UIImageView!
    @IBOutlet weak var rotationView: UIImageView!
    @IBOutlet weak var tipLabel: UILabel!
    @IBOutlet weak var loginBtn: UIButton!
    @IBOutlet weak var registerBtn: UIButton!
    
    // MARK:- 设置每个访客视图属性
    func setupVisitorViewInfo(imageName : String, title : String) {
        iconView.image = UIImage(named: imageName)
        tipLabel.text = title
        
        rotationView.hidden = true
    }
    
    // MARK:- 转盘动画
    func addRotation() {
        //创建动画
        let rotationAnim = CABasicAnimation(keyPath: "transform.rotation.z")
        
        //设置动画属性
        rotationAnim.fromValue = 0
        rotationAnim.toValue = M_PI * 2
        rotationAnim.repeatCount = MAXFLOAT
        rotationAnim.duration = 5
        rotationAnim.removedOnCompletion = false
        
        //添加动画
        rotationView.layer.addAnimation(rotationAnim, forKey: nil)
    }
}
